package com.gxan.web.controller.system;

import com.alibaba.fastjson.JSONObject;
import com.gxan.common.JsonResult;
import com.gxan.common.R;
import com.gxan.service.SystemService;
import com.gxan.service.system.SystemServiceImpl;
import com.gxan.utils.UploadFileUtil1;
import com.gxan.web.controller.BaseServlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;


@WebServlet("/system/*")
public class systemServlet extends BaseServlet {
    private SystemService service=new SystemServiceImpl();
    //新增部门
    public R adddepartment(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String dept_full_name = null;
        if(request.getParameter("dept_full_name")!=null&&!"".equals(request.getParameter("dept_full_name"))){
            dept_full_name = request.getParameter("dept_full_name");
        }
        System.out.println("dept_full_name="+dept_full_name);
        String dept_short_name = null;
        if(request.getParameter("dept_short_name")!=null&&!"".equals(request.getParameter("dept_short_name"))){
            dept_short_name = request.getParameter("dept_short_name");
        }
        System.out.println("dept_short_name="+dept_short_name);
        String dept_father = null;
        if(request.getParameter("dept_father")!=null&&!"".equals(request.getParameter("dept_father"))){
            dept_father = request.getParameter("dept_father");
        }
        System.out.println("dept_father="+dept_father);
        String dept_address = null;
        if(request.getParameter("dept_address")!=null&&!"".equals(request.getParameter("dept_address"))){
            dept_address = request.getParameter("dept_address");
        }
        System.out.println("dept_address="+dept_address);
        String common = null;
        if(request.getParameter("common")!=null&&!"".equals(request.getParameter("common"))){
            common = request.getParameter("common");
        }
        System.out.println("common="+common);
        String remark = null;
        if(request.getParameter("remark")!=null&&!"".equals(request.getParameter("remark"))){
            remark = request.getParameter("remark");
        }
        System.out.println("remark="+remark);
        String start = null;
        if(request.getParameter("start")!=null&&!"".equals(request.getParameter("start"))){
            start = request.getParameter("start");
        }
        System.out.println("start="+start);
        R r = service.addDepartment(dept_full_name, dept_short_name, dept_father, dept_address, common, remark, start);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));
        /**
         * common
         * dept_address
         * dept_father
         * dept_full_name
         * dept_short_name
         * remark
         * start
         */
        return null;
    }
    //查询用户表所有用户信息
    public JsonResult queryAllUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int currentPage = Integer.parseInt(request.getParameter("page"));
        int pageSize = Integer.parseInt(request.getParameter("limit"));

        JsonResult r = service.queryAllUser(currentPage,pageSize);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

        return r;
    }
    //新增用户信息
    public void addUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String login_name = null;
        if(request.getParameter("login_name")!=null&&!"".equals(request.getParameter("login_name"))){
            login_name = request.getParameter("login_name");
        }
        System.out.println("login_name="+login_name);
        int password = 0;
        if(request.getParameter("password")!=null&&!"".equals(request.getParameter("password"))){
            password = Integer.parseInt(request.getParameter("password"));
        }
        System.out.println("password="+password);
        String role = null;
        if(request.getParameter("role")!=null&&!"".equals(request.getParameter("role"))){
            role = request.getParameter("role");
        }
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        Integer phone = 0;
        if(request.getParameter("phone")!=null&&!"".equals(request.getParameter("phone"))){
            phone = Integer.parseInt(request.getParameter("phone"));
        }
        System.out.println("phone="+phone);
        R r=service.addUser(login_name,password,role,dept_name,phone);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //修改用户信息
    public void updateUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("修改用户信息");
        System.out.println(request.getParameterNames());
        int login_id = 0;
        if(request.getParameter("user_id")!=null&&!"".equals(request.getParameter("user_id"))){
            login_id = Integer.parseInt(request.getParameter("user_id"));
        }
        System.out.println("login_id"+login_id);
        String login_name = null;
        if(request.getParameter("login_name")!=null&&!"".equals(request.getParameter("login_name"))){
            login_name = request.getParameter("login_name");
        }
        System.out.println(login_name);
        System.out.println("login_name="+login_name);
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        System.out.println("dept_name="+dept_name);
        String phone = null;
        if(request.getParameter("phone")!=null&&!"".equals(request.getParameter("phone"))){
            phone = request.getParameter("phone");
        }
        String role = null;
        if(request.getParameter("role")!=null&&!"".equals(request.getParameter("role"))){
            role = request.getParameter("role");
        }
        R r=service.updateUser(login_id,login_name,role,dept_name,phone);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据id删除用户
    public void delUserById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("删除用户信息");

        int id = Integer.parseInt(request.getParameter("id"));
        System.out.println("id="+id);

        R r=service.delUserById(id);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }

    //多表查询根据用户名称用户角色用户部门
    public void selectByNameRoleDepartment(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询用户信息");

        String login_name =null;
        if(request.getParameter("login_name")!=null&&!"".equals(request.getParameter("login_name"))){
            login_name = request.getParameter("login_name");
        }
        String role =null;
        if(request.getParameter("role")!=null&&!"".equals(request.getParameter("role"))){
            role = request.getParameter("role");
        }
        String dept_name =null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        Integer page = Integer.parseInt(request.getParameter("page"));
        Integer limit = Integer.parseInt(request.getParameter("limit"));
        System.out.println("login_user="+login_name);
        System.out.println("role="+role);
        System.out.println("dept_name="+dept_name);
        System.out.println("page="+page);
        System.out.println("limit="+limit);

        JsonResult r=service.selectByNameRoleDepartment(login_name,role,dept_name,page,limit);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }

    //查看部门表（组织表）所有部门全称（要求不重复）
    public void selectAllDeptname(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询部门表全称信息");

        JsonResult r=service.selectAllDeptname();
        System.out.println("---------");
        System.out.println(r.getData());
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }

    //新增职位
    public void addPosition(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("addPosition-------");
        String job_name = request.getParameter("job_name");
        System.out.println("job_name="+job_name);
        String job_type = request.getParameter("job_type");
        System.out.println("job_type="+job_type);
        String dept_name = request.getParameter("dept_name");
        System.out.println("dept_name="+dept_name);
        String description = request.getParameter("description");
        System.out.println("description="+description);
        String remark = request.getParameter("remark");
        System.out.println("remark="+remark);
        Integer status = Integer.parseInt(request.getParameter("status"));
        System.out.println("status="+status);
        R r=service.addPosition(job_name,job_type,dept_name,description,remark,status);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }

    //查询所有职位表信息
    public JsonResult selectAllPosition(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int currentPage = Integer.parseInt(request.getParameter("page"));
        int pageSize = Integer.parseInt(request.getParameter("limit"));

        JsonResult r = service.selectAllPosition(currentPage,pageSize);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

        return r;
    }

    //根据职位id删除职位表数据
    public void deletePositionById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("删除职位信息");

        int id = Integer.parseInt(request.getParameter("id"));
        System.out.println("id="+id);

        R r=service.deletePositionById(id);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据职位id修改职位表数据
    public void updatePositionById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("修改职位信息");
        Integer job_id = Integer.parseInt(request.getParameter("job_id"));
        System.out.println("addPosition-------job_id="+job_id);
        String job_name =null;
        if(request.getParameter("job_name")!=null &&!"".equals(request.getParameter("job_name"))){
            job_name = request.getParameter("job_name");
        }
        System.out.println("job_name="+job_name);
        String job_type =null;
        if(request.getParameter("job_type")!=null &&!"".equals(request.getParameter("job_type"))){
            job_type = request.getParameter("job_type");
        }
        System.out.println("job_type="+job_type);
        String dept_name =null;
        if(request.getParameter("dept_name")!=null &&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        System.out.println("dept_name="+dept_name);
        String description =null;
        if(request.getParameter("description")!=null &&!"".equals(request.getParameter("description"))){
            description = request.getParameter("description");
        }
        System.out.println("description="+description);
        String remark =null;
        if(request.getParameter("remark")!=null &&!"".equals(request.getParameter("remark"))){
            remark = request.getParameter("remark");
        }
        System.out.println("remark="+remark);
        Integer status = -1;
        if(request.getParameter("status")!=null &&!"".equals(request.getParameter("status"))){
            status = Integer.parseInt(request.getParameter("status"));
        }

        System.out.println("status="+status);
        R r=service.updatePositionById(job_id,job_name,job_type,dept_name,description,remark,status);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据职位名称，所属部门和是否启用查职位表
    public void selectPositionByNameDepartmentStart(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询职位表信息");

        String job_name = request.getParameter("job_name");
        System.out.println("job_name="+job_name);
        int status =-1;
        if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
            status=Integer.parseInt(request.getParameter("status"));
        }
        System.out.println("status="+status);
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }

        System.out.println("dept_name="+dept_name);
        Integer page = Integer.parseInt(request.getParameter("page"));
        System.out.println("page="+page);
        Integer limit = Integer.parseInt(request.getParameter("limit"));
        System.out.println("limit="+limit);

        JsonResult r=service.selectPositionByNameDepartmentStart(job_name,dept_name,status,page,limit);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //添加职称
    public void addJobtitle(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("addPosition-------");
        String job_title_name = request.getParameter("job_title_name");
        System.out.println("job_title_name="+job_title_name);
        String dept_name = request.getParameter("dept_name");
        System.out.println("dept_name="+dept_name);
        String description = request.getParameter("description");
        System.out.println("description="+description);
        String remark = request.getParameter("remark");
        System.out.println("remark="+remark);
        Integer status = Integer.parseInt(request.getParameter("status"));
        System.out.println("status="+status);
        R r=service.addJobtitle(job_title_name,dept_name,description,remark,status);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //查职称表的全部信息
    public void selectJobtitleAll(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int currentPage = Integer.parseInt(request.getParameter("page"));
        int pageSize = Integer.parseInt(request.getParameter("limit"));

        JsonResult r = service.selectJobtitleAll(currentPage,pageSize);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

        return ;
    }
    //根据职称id删除职称表数据
    public void deleteJobtitleById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("删除职称信息");

        int id = Integer.parseInt(request.getParameter("id"));
        System.out.println("id="+id);

        R r=service.deleteJobtitleById(id);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据职称id修改职称表数据
    public void updateJobtitleById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("修改职称信息");
        Integer job_title_id = Integer.parseInt(request.getParameter("job_title_id"));
        System.out.println("addPosition-------job_title_id="+job_title_id);
        String job_title_name =null;
        if(request.getParameter("job_title_name")!=null &&!"".equals(request.getParameter("job_title_name"))){
            job_title_name = request.getParameter("job_title_name");
        }
        System.out.println("job_title_name="+job_title_name);
        String dept_name =null;
        if(request.getParameter("dept_name")!=null &&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        System.out.println("dept_name="+dept_name);
        String description =null;
        if(request.getParameter("description")!=null &&!"".equals(request.getParameter("description"))){
            description = request.getParameter("description");
        }
        System.out.println("description="+description);
        String remark =null;
        if(request.getParameter("remark")!=null &&!"".equals(request.getParameter("remark"))){
            remark = request.getParameter("remark");
        }
        System.out.println("remark="+remark);
        Integer status = -1;
        if(request.getParameter("status")!=null &&!"".equals(request.getParameter("status"))){
            status = Integer.parseInt(request.getParameter("status"));
        }

        System.out.println("status="+status);
        R r=service.updateJobtitleById(job_title_id,job_title_name,dept_name,description,remark,status);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据职称名称，所属部门和是否启用查职称表
    public void selectJobtitleByNameDepartmentStatus(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询职称表信息");

        String job_title_name = null;
        if(request.getParameter("job_title_name")!=null&&!"".equals(request.getParameter("job_title_name"))){
            job_title_name=request.getParameter("job_title_name");
        }
        System.out.println("job_title_name="+job_title_name);
        int status =-1;
        if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
            status=Integer.parseInt(request.getParameter("status"));
        }
        System.out.println("status="+status);
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }

        System.out.println("dept_name="+dept_name);
        Integer page = Integer.parseInt(request.getParameter("page"));
        System.out.println("page="+page);
        Integer limit = Integer.parseInt(request.getParameter("limit"));
        System.out.println("limit="+limit);

        JsonResult r=service.selectJobtitleByNameDepartmentStatus(job_title_name,dept_name,status,page,limit);
        System.out.println(r.getData());
        System.out.println("多条件查询返回值给页面");
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //上传文件
    public void uploadFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询职称表信息");
        R r = new R();
        boolean upload = UploadFileUtil1.upload(request);
        if(upload){
            r.setData(UploadFileUtil1.formData);
            r.setCode(0);
        }

        System.out.println("多条件查询返回值给页面");
        //回写响应
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //新增试题
    public void addTest(HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException, ParseException {
        System.out.println("addTest-------");
        String test_title = request.getParameter("test_title");
        System.out.println("test_title="+test_title);
        String test_type = request.getParameter("test_type");
        System.out.println("test_type="+test_type);
        String dept_name = request.getParameter("dept_name");
        System.out.println("dept_name="+dept_name);
        String test_level = request.getParameter("test_level");
        System.out.println("test_level="+test_level);
        String test_setter = request.getParameter("test_setter");
        System.out.println("test_setter="+test_setter);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        if(request.getParameter("test_set_time")!=null &&!"".equals(request.getParameter("test_set_time"))){
            date =df.parse(request.getParameter("test_set_time"));
        }

        System.out.println("date="+date);
        Integer status = 0;
        if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
            status=Integer.parseInt(request.getParameter("status"));
        }
        System.out.println("status="+status);
        String test_content = request.getParameter("test_content");
        System.out.println("test_content="+test_content);
        String remark = request.getParameter("remark");
        System.out.println("remark="+remark);
        String test_url=null;
        //从session域中获取images数据
        ArrayList<String> images = (ArrayList<String>) request.getSession().getAttribute("images");
        String[] imgs = null;
        if (images != null && images.size() > 0) {
            imgs = images.toArray(new String[0]);
            //图片数组处理成字符串    a.jpg;b.jpeg;c.png
            String result = "";
            for (int i = 0; i < imgs.length; i++) {
                result += i == imgs.length - 1 ? imgs[i] : imgs[i] + ";";
            }
            test_url=result;
        }
        R r=service.addTest(test_title,test_type,dept_name,test_level,test_setter,date,test_content,remark,test_url,status);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //查看试题所有信息
    public void selectTestAll(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int currentPage = Integer.parseInt(request.getParameter("page"));
        int pageSize = Integer.parseInt(request.getParameter("limit"));

        JsonResult r = service.selectTestAll(currentPage,pageSize);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

        return ;
    }
    //根据id修改试题信息
    public void updateTestById(HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException, ParseException {
        System.out.println("updateTestById-------");
        Integer test_id = 0;
        if(request.getParameter("test_id")!=null&&!"".equals(request.getParameter("test_id"))){
            test_id =Integer.parseInt(request.getParameter("test_id")) ;
        }
        System.out.println("test_id="+test_id);
        String test_title = null;
        if(request.getParameter("test_title")!=null&&!"".equals(request.getParameter("test_title"))){
            test_title = request.getParameter("test_title");
        }
        System.out.println("test_title="+test_title);
        String test_type = null;
        if(request.getParameter("test_type")!=null&&!"".equals(request.getParameter("test_type"))){
            test_type = request.getParameter("test_type");
        }
        System.out.println("test_type="+test_type);
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        System.out.println("dept_name="+dept_name);
        String test_level = null;
        if(request.getParameter("test_level")!=null&&!"".equals(request.getParameter("test_level"))){
            test_level = request.getParameter("test_level");
        }
        System.out.println("test_level="+test_level);
        String test_setter = null;
        if(request.getParameter("test_setter")!=null&&!"".equals(request.getParameter("test_setter"))){
            test_setter = request.getParameter("test_setter");
        }
        System.out.println("test_setter="+test_setter);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        System.out.println("时间："+date);
        if(request.getParameter("test_set_time")!=null &&!"".equals(request.getParameter("test_set_time"))){
            date =df.parse(request.getParameter("test_set_time"));
        }

        System.out.println("date="+date);
        Integer status = 0;
        if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
            status=Integer.parseInt(request.getParameter("status"));
        }
        System.out.println("status="+status);
        String test_content = null;
        if(request.getParameter("test_content")!=null&&!"".equals(request.getParameter("test_content"))){
            test_content = request.getParameter("test_content");
        }
        System.out.println("test_content="+test_content);
        String remark = null;
        if(request.getParameter("remark")!=null&&!"".equals(request.getParameter("remark"))){
            remark = request.getParameter("remark");
        }
        System.out.println("remark="+remark);
        String test_url=null;
        //从session域中获取images数据
        ArrayList<String> images = (ArrayList<String>) request.getSession().getAttribute("images");
        String[] imgs = null;
        if (images != null && images.size() > 0) {
            imgs = images.toArray(new String[0]);
            //图片数组处理成字符串    a.jpg;b.jpeg;c.png
            String result = "";
            for (int i = 0; i < imgs.length; i++) {
                result += i == imgs.length - 1 ? imgs[i] : imgs[i] + ";";
            }
            test_url=result;
        }
        R r=service.updateTestById(test_id,test_title,test_type,dept_name,test_level,test_setter,date,test_content,remark,test_url,status);
        System.out.println(r.getData());
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }
    //根据id删除试题表信息
    public void deleteTestById(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("删除试题信息");

        int id = Integer.parseInt(request.getParameter("id"));
        System.out.println("id="+id);

        R r=service.deleteTestById(id);
        System.out.println(r);
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }


    public void selectTestByTitleTypeDepartmentStart(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println("查询试题表信息");

        String test_title = null;
        if(request.getParameter("test_title")!=null&&!"".equals(request.getParameter("test_title"))){
            test_title = request.getParameter("test_title");
        }
        System.out.println("test_title="+test_title);
        String test_type = null;
        if(request.getParameter("test_type")!=null&&!"".equals(request.getParameter("test_type"))){
            test_type = request.getParameter("test_type");
        }
        System.out.println("test_type="+test_type);
        int status =-1;
        if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
            status=Integer.parseInt(request.getParameter("status"));
        }
        System.out.println("status="+status);
        String dept_name = null;
        if(request.getParameter("dept_name")!=null&&!"".equals(request.getParameter("dept_name"))){
            dept_name = request.getParameter("dept_name");
        }
        System.out.println("dept_name="+dept_name);
        Integer page = Integer.parseInt(request.getParameter("page"));
        System.out.println("page="+page);
        Integer limit = Integer.parseInt(request.getParameter("limit"));
        System.out.println("limit="+limit);

        JsonResult r=service.selectTestByTitleTypeDepartmentStart(test_title,test_type,dept_name,status,page,limit);
        System.out.println(r.getData());
        System.out.println("多条件查询返回值给页面");
        //回写响应
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));

    }




}
